package com.xdf.docmanagementsystem.controller;

import com.xdf.docmanagementsystem.entity.ResponseResult;
import com.xdf.docmanagementsystem.enums.ResponseEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @program: doc-management-system
 * @description: 全部异常捕获
 * @author: Zhang
 * @create: 2020-06-19 16:30
 **/
@RestControllerAdvice
public class GlobalExceptionHandlerController {

    /**
     * 捕获全局异常提示,向前端抛出JSON对象
     *
     * @param e
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    public ResponseResult<Void> ExceptionHandler(Exception e) {
        return new ResponseResult<Void>(false, ResponseEnum.NOT_ALLOW.getState(), e.getMessage());
    }
}
